/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       weekly_generator.h

	$Header: /game/weekly_generator.h $

	$NoKeywords: $

 ************************************************************************/

#ifndef WEEKLY_GENERATOR_H_INCLUDED
#define WEEKLY_GENERATOR_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "material_amount.h"
#include "owned_scriptable_adv_object.h"
#include "player_color.h"

// -------------------------------------------------------------------
// generator which produces material once per week
// -------------------------------------------------------------------
class t_weekly_generator : public t_owned_scriptable_adv_object
{
public:
	t_weekly_generator( std::string const& source,
		                t_qualified_adv_object_type const& type );
	t_weekly_generator( t_material type, t_player_color owner_color = k_player_gray );

	virtual void         activate_trigger( t_army* army, t_adv_map_point const& point, 
		                                   t_direction direction, t_adventure_frame* frame );
	virtual float		 ai_value( t_adventure_ai const& ai, t_creature_array const& army, int move_cost ) const;	
	t_material           get_material() const;
	int                  get_production() const;
	static int           get_production( t_material type );
	virtual int			 get_version() const;
	virtual void		 place( t_adventure_map& map, t_adv_map_point const& point );
	virtual void         process_new_day();
	virtual bool         read( std::streambuf&						stream, 
						       t_qualified_adv_object_type const&	type,
						       int									version );
	virtual bool         read_from_map( std::streambuf& buffer, t_progress_handler* );
	virtual void		 right_click( t_mouse_event const& event,
								      t_adventure_frame* adventure_frame );
	virtual void         set_owner( int player_number );
	virtual bool         write( std::streambuf& stream ) const;	

protected:
	void reset( t_material material );

	t_material_amount m_material;
	int				  m_production_time; // 0-7 days.
};

inline t_material t_weekly_generator::get_material() const
{
	return t_material( get_major_subtype() );
}

inline int t_weekly_generator::get_production() const
{
	return get_production( m_material.material );
}

// -------------------------------------------------------------------
// random weekly generator which produces material once per week
// -------------------------------------------------------------------
class t_random_weekly_generator : public t_owned_scriptable_adv_object
{
public:
	t_random_weekly_generator( std::string const& source );

	virtual void place( t_adventure_map& map, t_adv_map_point const& point );
	virtual bool read_from_map( std::streambuf& buffer, t_progress_handler* );
};

#endif // WEEKLY_GENERATOR_H_INCLUDED
